@extends("backend.layout.main")

@section("before.css")
    <link type="text/css" href="/backend/css/common.css" rel="Stylesheet">
    <link type="text/css" href="/backend/css/header.css" rel="Stylesheet">

    <link type="text/css" href="/backend/css/style2.css" rel="Stylesheet">
    <link type="text/css" href="/backend/css/project.css" rel="Stylesheet">



<script type="text/javascript">
$(function(){

    $('.perMesg').mouseenter(function(){
        $(this).find('dd').addClass('showTrsm');
      }).mouseleave(function(){
        $(this).find('dd').removeClass('showTrsm');
      })
});
</script>
    @endsection

    @section("right_content")
    <!--middle-->
     <div class="mainWrapBox">
        <div class="mainBox">


<div class="html">
    <div class="body">
        <div class="pro_main left">
            <!--filter-->
            <div class="filter-panel">

                    <input type="hidden" name="my" id="my">
                    <input type="hidden" name="auditor" id="auditor">
                    <input type="hidden" name="dept" id="dept">
                    <input type="hidden" name="status" id="status">
                    <input type="hidden" name="depId" id="depId">
                    <input type="hidden" name="userId" id="userId">




                 <div class="filter-cell-search left">
                    <!---->
                    <div class="search_divs">
                        <input class="input" style="width: 200px;" placeholder="搜索" id="keyword">

                        <input type="button" class="icon-search" id="searchButton" onclick="search()">

                    </div>
                    <!---->
                </div>
                <div class="right">
                 @if(session()->get('member')['gid']==1)
                    <div class="left mt20 ml20">
                      <a id="addContract" class="btn green" href="/backend/items/create">创建项目</a>
                    </div>
                @else
                @endif
                </div>
                <div class="cl"></div>
            </div>
            <div class="cl"></div>
            <!---->
        </div>
    </div>
</div>
<!--bumen-->
<div class="html">
    <div class="body">
        <div class="pro_main left">
            <!-- Table-->
            <div id="pro_list">

                    <div class="table-content colorwihte left">
                        <table cellpadding="0" cellspacing="0" class="table left">
                            <thead class="table-header" id="thead">
                            <tr>
                                <th width="120" class="sort" data-column="1">
                                    <div class="sort-float-left">项目编号</div>
                                    <span class="sort-desc"></span>
                                </th>
                                <th width="120" class="sort" data-column="2">
                                    <div class="sort-float-left">
                                    <select id="project-type" class="project-title">

                                        <option value="">项目类型</option>
                                        <option value="10">庭院景观</option>

                                    </select>
                                    </div>
                                </th>
                                <th width="120" class="sort" data-column="3">
                                    <div class="sort-float-left">
                                    <select id="project-status" class="project-title">

                                        <option value="">项目状态</option>
                                        <option value="-1">未开始</option>
                                        <option value="1">进行中</option>
                                        <option value="2">已完成</option>


                                    </select>
                                    </div>
                                </th>
                                <th width="120" class="sort" data-column="4">
                                    <div class="sort-float-left">
                                     <select id="project-stage" class="project-title">

                                        <option value="">项目阶段</option>
                                         <option value="1">初步</option>
                                         <option value="2">扩初</option>
                                         <option value="3">施工图</option>

                                    </select>
                                 </div>
                                </th>
                                <th width="120" class="sort" data-column="5">
                                    <div class="sort-float-left">项目名称</div>
                                </th>

                                <th width="120" class="sort" data-column="7">
                                    <div class="sort-float-left">商务经理</div>
                                </th>
                                <th width="120" class="sort" data-column="8">
                                    <div class="sort-float-left">项目进度</div>
                                </th>
                                <th width="100">操作</th>
                            </tr>

                            </thead>


                            <tbody class="table-body">
                            @if($itemsInfo)
                                @foreach($itemsInfo as $item=>$value)
                                <tr>
                                    <td>{{ $value['id'] }}</td>
                                    <td>
                                    {{ trans('items.item_type_'.$value['item_type']) }}
                                    </td>
                                    <td>
                                        <div class="status-tag">
                                           <span class="selected-text"> {{ trans('items.item_status_'.$value['item_status']) }} </span>
                                        </div>
                                    </td>
                                    <td>{{ trans('items.item_stage_'.$value['item_stage']) }}</td>
                                    <td>
                                        <div class="content-2line">
                                                <a class="underline" title="{{ $value['item_name'] }}" style="width:350px;display:block; overflow:hidden;" href="/backend/items/task/{{ $value['id'] }}">{{ $value['item_name'] }}</a>
                                        </div>
                                    </td>

                                    <td><span>{{ $value['username'] }}</span></td>
                                    <td><span>{{ $value['item_plan'] }}</span></td>
                                    <td>
                                       <a class="underline" href="/backend/items/task/{{ $value['id'] }}">查看</a>
                                    @if(session()->get('member')['gid']==1)
                                        <a onClick="return confirm('确认要删除？')" href="/backend/items/delete/{{ $value['id'] }}" class="underline">删除</a>
                                    @else

                                    @endif 
                                    </td>
                                </tr>
                                @endforeach
                            @endif

                            </tbody>
                        </table>
                        <div class="pagination">

                            {!! $itemsInfo->appends($appends)->links() !!}

                            <input type="hidden" id="page" name="page">
                            </div>
                        <table class="table">
                            <tbody>
                            <tr>

                            </tr>
                            </tbody>
                        </table>
                    </div>
              </div>
          </div>
         <div class="cl"></div>
        <!---->
       </div>
      </div>

<!--gs-->
    </div>
   </div>
  </div>
</div>

    <script>
        //搜索
        $(function(){

            var stage="{{ $appends['stage'] or ''}}";
            var status="{{ $appends['status'] or ''}}";
           var  type="{{ $appends['type'] or ''}}";
            var keyword="{{ $appends['keyword'] or ''}}";

            $("#project-stage").val(stage);
            $("#project-status").val(status);
            $("#project-type").val(type);
            $("#keyword").val(keyword);
        })

        function search(){

            var type=$('#project-type').val();
            var status=$('#project-status').val();
            var stage=$('#project-stage').val();
            var keyword=$('#keyword').val();


            var url='/backend/items?';

            if(keyword){
                keyword="keyword="+keyword+"&";
            }
            if(type){
                type="type="+type+"&";
            }
            if(stage){
                stage="stage="+stage+"&";
            }
            if(status){
                status="status="+status+"&";
            }
            url=url+stage+status+type+keyword;
            url= url.substring(0, url.lastIndexOf('&'));
            location.href=url;
        }

        $('.sort-float-left select').change(function(){
            search();

        })


    </script>


@endsection